package com.spring.boot.demo.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ZhuYouBin
 * @version 1.0.0
 * @Date: 2022/10/27 12:41
 * @Description
 */
// 将当前类添加到 IOC 容器里面
@Component
public class TaskDemo {

    /**
     * 使用注解设置定时任务执行时间
     */
//    @Scheduled(cron = "0/10 * * * * ? ")
    public void runTask() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = sdf.format(new Date());
        System.out.println("执行runTask方法: " + date);
    }

}
